<?php
/**
 * A simple description for this script
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Paylog
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
 *
 */

class Paylog_Abstract_PageController extends Paylog_Abstract_Controller
{
	protected $menu = array(
		'month'   => null,
		'start'   => null,
		'end'     => null,
		'book_id' => null,
	);

	public function __construct()
	{
		parent::__construct();

		if ( isset($this->session['menu']) and is_array($this->session['menu']) )
		{
			foreach ( $this->menu as $key => $item )
			{
				if ( isset($this->session['menu'][$key]) )
				{
					$this->menu[$key] = $this->session['menu'][$key];
				}
			}
		}

		foreach ( $this->menu as $key => $item )
		{
			$this->menu[$key] = Paylog::get($key, $item);
		}

		foreach ( $this->menu as $key => $item )
		{
			$this->output['menu'][$key]  =& $this->menu[$key];
			$this->session['menu'][$key] =& $this->menu[$key];
		}
	}

	protected function _validateDate($date)
	{
		if ( preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $date, $match) )
		{
			list($all, $year, $month, $day) = $match;
			return checkdate($month, $day, $year);
		}

		return false;
	}
}

?>
